<HTML><HEAD><TITLE>matchsub(+Pattern, +String, +Options, -SubMatches)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(regex)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>matchsub(+Pattern, +String, +Options, -SubMatches)</H1>
A substring of String matches the regular expression Pattern and SubMatches are matching sub-expressions
<DL>
<DT><EM>Pattern</EM></DT>
<DD>A string (or a compiled pattern handle)
</DD>
<DT><EM>String</EM></DT>
<DD>A string
</DD>
<DT><EM>Options</EM></DT>
<DD>List of atoms
</DD>
<DT><EM>SubMatches</EM></DT>
<DD>Output: List of strings
</DD>
</DL>
<H2>Description</H2>

	Succeeds if all or a substring of String matches the regular
	expression Pattern. For the description of regular expressions
	see the library(regex) page.
	<P>
    	Options is a (possibly empty) list of atomic option names,
	as described in the library(regex) page.
	<P>
	SubMatches is bound to a list of strings, each corresponding to
	a parenthesized subexpression in Pattern. These subexpressions
	are ordered according to the position of their opening parenthesis
	within the pattern. The matching string appears on the corresponding
	position in the SubMatches list. Note that, if a subexpression matches
	several times, only the last match is returned.
	<P>
    
<H3>Modes and Determinism</H3><UL>
<LI>matchsub(+, +, +, -) is semidet
</UL>
<H3>Fail Conditions</H3>
String does not match Pattern
<H2>Examples</H2>
<PRE>
    ?- matchsub("Name:([^,]+), Age:([0-9]+),", "Name:Fred, Age:34,", [], L).
    L = ["Fred", "34"]
    Yes
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/regex/index.html">library(regex)</A>, <A HREF="../../lib/regex/match-2.html">match / 2</A>, <A HREF="../../lib/regex/match-3.html">match / 3</A>, <A HREF="../../lib/regex/match-4.html">match / 4</A>, <A HREF="../../lib/regex/compile_pattern-3.html">compile_pattern / 3</A>
</BODY></HTML>
